from django.db import models


class Teacher(models.Model):
    name = models.CharField(max_length=30, verbose_name='老师名')
    age = models.IntegerField(verbose_name='年纪')

    def __str__(self):
        return self.name


class Student(models.Model):
    name = models.CharField(max_length=30, verbose_name='学生名')
    teacher = models.ForeignKey(
        Teacher, on_delete=models.SET_NULL,
        null=True, blank=True,
        verbose_name='关联老师'
    )

    def __str__(self):
        return self.name
